<template>
	<div class="invitedClass">
		<div class="classIndex_h">
			<span>受邀评课</span>
		</div>
		<!--  -->
		<div class="classNotice_search clear">
			<el-input class="classNotice_sc fl" placeholder="课程名称" prefix-icon="el-icon-search" v-model="searchVal" @change="changSelected">
			</el-input>
		</div>
		<div class="myCourse_l" v-loading="loading">
			<ul>
				<li class="invitedClass_ls" v-for="(item, index) in evaList" :key="index">
					<div class="invitedClass_ls1 clear">
						<a @click="openNetteach(item.id)">{{item.name}}</a>
						<div class="resource_ioperation fr" v-if="item._status==='已结束'">
							<el-popover placement="bottom" width="" popper-class="ioperation_hover" trigger="hover">
								<ul class="r_ioperation">
									<li @click="removeList(item.id)">删除</li>
								</ul>
								<i slot="reference" class="el-icon-arrow-down"></i>
							</el-popover>
						</div>
					</div>
					<!--  -->
					<div class="invitedClass_ls2">
						<i class="ipm yiping" v-if="item.is_ping >= 1"></i>
						<i class="ipm weiping" v-else></i>
						<span>
							{{item.start_time.substring(0,10)}} - {{item.end_time.substring(0,10)}}
						</span>
					</div>
					<!--  -->
					<div class="invitedClass_ls3" v-html="item.profile"></div>
					<!--  -->
					<div class="invitedClass_ls4">
						<span>视频文件：{{item.video_num}}</span>
						<span> 参与人数：{{item.total_user}}</span>
					</div>
					<!--  -->
					<div class="invitedClass_ls5">
						<span>发起者：{{item.user_name}}</span>
						<span>{{item.org_name}}</span>
						<div class="fr">
							得分:<strong>{{item.total_average_score}}</strong>
						</div>
					</div>
				</li>
			</ul>
		</div>
		<div class="pageBox" v-if="total_number > page_size">
			<el-pagination @current-change="change_page" :current-page="page_index" :page-size="page_size" layout="prev, pager, next" :total="total_number">
			</el-pagination>
		</div>
		<div class="dependent" v-if="placeholder">
			<i class="ipm image_nofound"></i>
			<p>
				还没发现任何相关的内容哦~
			</p>
		</div>
	</div>
</template>
<script>
export default {
	name: '',
	data() {
		return {
			evaList: [],
			page_index: 1,
			page_size: this.$g.page_size,
			total_number: 0,
			searchVal: '',
			placeholder: false,
			loading: true
		}
	},
	created() {
		this.getEvaList()
	},
	methods: {
		/*
			跳转到网络教研模块查看视频
		 */
		openNetteach(id) {
			let BASE_URL = sessionStorage.getItem('host_addr')
			let redirect_params = sessionStorage.getItem('redirect_params')
			window.open(BASE_URL + ':8083' + redirect_params + '/netteach?id=' + id)
		},
		getEvaList() {
			let success = (res => {
				let data = res.data;
				this.evaList = data.data;
				this.page_index = parseInt(data.page_index);
				this.total_number = data.data_sum;

				this.loading = false
				this.evaList.length === 0 ?
					this.placeholder = true :
					this.placeholder = false
			});
			this.$ajax({
				url: 'api/network/eva_list',
				method: 'get',
				params: {
					userid: this.$g.user_id,
					eva_type: 2,
					eva_status: 0,
					page_index: this.page_index,
					page_size: this.page_size,
					keyword: this.searchVal,
				},
				func: {
					success: success
				}
			})
		},
		//分页
		change_page(val) {
			this.page_index = val;
			this.getEvaList()
		},
		//搜索
		changSelected() {
			this.page_index = 1;
			this.getEvaList()
		},
		//删除
		removeList(res_id) {
			this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning',
				customClass: 'confirm-them',
			}).then(() => {
				let success = (res => {
					let data = res.data;
					this.getEvaList()
				});
				this.$ajax({
					url: 'api/network/eva_list',
					method: 'delete',
					params: {
						id: res_id
					},
					func: {
						success: success
					}
				})
			}).catch(() => {});
		},

	}
}
</script>